#pragma once

#include <boost/asio.hpp>
#include <tbb/tbb_thread.h>


/// Naive implementation of HTTP server
class SimpleTcpServer
{
public:
	/// Constructs the server to listen to the specified port using the given io_service
	SimpleTcpServer(unsigned short port = 80);

	/// Run the server's io_service loop
	void Run(bool showStat = false);

private:
	/// Method executed by each connection thread
	static void ConnectionThreadProc(tbb::tbb_thread **self);

	/// The io_service used to perform asynchronous operations.
	boost::asio::io_service _ioService;

	/// Acceptor used to listen for incoming connections
	boost::asio::ip::tcp::acceptor _acceptor;
};
